package com.sl.water.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sl.water.dao.PlanControlFhzDao;
import com.sl.water.entity.PlanControlFhz;
import com.sl.water.entity.RehearsalScheme;
import com.sl.water.service.PlanControlFhzService;
import com.sl.water.vo.BaseVO;
import com.sl.water.vo.PlanControlFhzVO;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:分洪闸调度 服务接口实现
 * @author: duan
 * @time: 2025-06-26 14:37
 */
@Service
public class PlanControlFhzServiceImpl extends ServiceImpl<PlanControlFhzDao, PlanControlFhz> implements PlanControlFhzService {


    @Override
    public void removeByPlanId(Long planId) {
        LambdaQueryWrapper<PlanControlFhz> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(PlanControlFhz::getPlanId, planId);
        this.remove(lambdaQueryWrapper);
    }

    @Override
    public void saveByRehearsalScheme(Long planId, RehearsalScheme rehearsalScheme) {
        PlanControlFhz planControlFhz = PlanControlFhz.builder()
                .planId(planId)
                .zmkqsj(rehearsalScheme.getZmkqsj())
                .zmkd(rehearsalScheme.getZmkd())
                .fhFlow(rehearsalScheme.getFhFlow()).build();
        this.save(planControlFhz);
    }

    @Override
    public List<PlanControlFhzVO> queryByPlanID(Long id) {
        LambdaQueryWrapper<PlanControlFhz> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(PlanControlFhz::getPlanId, id);
        return BaseVO.convertList(this.list(lambdaQueryWrapper), PlanControlFhzVO.class);
    }
}
